package com.example.test_bluetooth;

import java.util.HashMap;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class listeClient  extends ListActivity{
	 private TextView selection;
	   private enum Semaine {Lundi, Mardi, Mercredi, Jeudi, Vendredi, Samedi, Dimanche};
	   
	   @Override
	   public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.activity_choixliste);
	       // Intent intent = getIntent();
	      
			//HashMap<String, String> hashMap = (HashMap<ThreadSocketTransfert, String>)intent.getSerializableExtra("map");
	      //  Log.v("HashMapTest", hashMap.get("key"));
	        setListAdapter(new ArrayAdapter<Semaine>(this, android.R.layout.simple_list_item_multiple_choice, Semaine.values()));
	        getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
	        selection = (TextView) findViewById(R.id.selection);
	   }

	   @Override
	   protected void onListItemClick(ListView liste, View v, int position, long id) {
	      String resultat = "";
	      Semaine semaine;
	      SparseBooleanArray tableau = liste.getCheckedItemPositions();
	      for (int i=0; i<tableau.size(); i++) {
	         if (tableau.valueAt(i)) {
	            semaine = (Semaine) getListAdapter().getItem(tableau.keyAt(i));
	            resultat += semaine.name() + " ";
	         }
	      }
	      selection.setText("["+resultat+"]");
	   } 
}
